package com.deke.home.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.deke.entity.TbZone;
import com.deke.entity.TbZoneCourse;
import com.deke.home.dao.TbZoneCourseDao;
import com.deke.home.service.TbZoneCourseService;
import com.deke.home.vo.TbZoneCourseVo;
import com.deke.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * @author ：ludi（206913808@qq.com）
 * @date ：Created in 2022/12/11 14:59
 * @description：
 * @modified By：
 * @version:
 */
@Service
public class TbZoneCourseServiceImpl implements TbZoneCourseService {

    @Autowired
    private TbZoneCourseDao tbZoneCourseDao;


    /**
     * @return com.deke.vo.Result<com.badmouth.mybatis plus.core.metadata.IPage < com.deke.entity.TbZoneCourse>>
     * @create by: ludi（206913808@qq.com）
     * @description: 分页查询、条件查询
     * @create time: 2022/12/11 15:00
     */
    @Override
    public Result<IPage<TbZoneCourse>> queryByConditionPage(Integer current, Integer pageSize, TbZoneCourse tbZoneCourse) {
        IPage<TbZoneCourse> page = new Page(current,pageSize);
        QueryWrapper<TbZoneCourse> wrapper = new QueryWrapper<>();
        wrapper.eq("is_deleted",0);
        if (StringUtils.hasText(tbZoneCourse.getId())){
            wrapper.like("id",tbZoneCourse.getId());
        }
        IPage<TbZoneCourse> iPage = tbZoneCourseDao.selectPage(page, wrapper);
        return new Result<>(2000,"查询成功",iPage);
    }


    /**
     * @create by: ludi（206913808@qq.com）
     * @description: 前端查询
     * @create time: 2022/12/19 16:23
     * @param
     * @return com.deke.vo.Result
     */
    @Override
    public Result getAllQianZone() {
        List<TbZoneCourse> tbZoneCourses = tbZoneCourseDao.selectList(null);
        return new Result(2000, "查询成功", tbZoneCourses);
    }
}